home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
qbtools1.arc
/
AEQKSORT.BAS
< prev
next >
Wrap
BASIC Source File
|
1987-01-11
|
768b
|
37 lines
rem $linesize:132
rem $title:'Application Engineer Standard Routines'
rem $subtitle:'Perform QuickSort on string array'
' Include the COMMON values
rem $include:'AESHARED.BAS'
sub qsort(fl$(1),elements%) static
dim stack(30,2)
s=1:stack(1,1)=1:stack(1,2)=elements%
while s<>0
l=stack(s,1):r=stack(s,2):s=s-1
while l<r
i=l:j=r:x$=fl$((l+r)/2)
while j>=i
while fl$(i)<x$
i=i+1
wend
while x$<fl$(j)
j=j-1
wend
if i<=j then
swap fl$(j),fl$(i)
i=i+1
j=j-1
end if
wend
if i<r then
s=s+1
stack(s,1)=i
stack(s,2)=r
end if
r=j
wend
wend
end sub